package cn.asterly.cicada.web.controller;

import cn.asterly.cicada.common.model.DataTablesResult;
import cn.asterly.cicada.common.model.Result;
import cn.asterly.cicada.model.Log;
import cn.asterly.cicada.service.ILogService;
import cn.asterly.cicada.service.impl.LogServiceImpl;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @ Author     ：likun
 * @ Date       ：Created in 16:22 2019-02-28
 * @ Description：日志类
 * @Version: $
 */
@RestController
@RequestMapping("/loginfo")
@Api(value = "logInfoController",description = "日志信息类")
public class LogInfoController implements BaseController<Log>{

    @Autowired
    private ILogService service;

    @Override
    public Result<Log> addition(Log log) {
        return null;
    }

    @Override
    public Result<Log> editInfo(Log log) {
        return null;
    }

    @Override
    public Result delById(String id) {
        return null;
    }

    @Override
    @RequestMapping("/sellogid/{id}")
    @ApiOperation(value = "根据id查询所有的日志信息",httpMethod = "GET")
    public Result selById(@PathVariable String id) {
        return new Result(true,"id="+id,5200,service.selectByPrimaryKey(id));
    }

    @Override
    @RequestMapping("/sellogall")
    @ApiOperation(value = "查询所有的日志信息",httpMethod = "GET")
    public DataTablesResult selByAll() {
        return new DataTablesResult(true,"日志记录",5200,service.selAll());
    }

    @RequestMapping("/sellog/{page}")
    @ApiOperation(value = "查询指定页的日志信息",httpMethod = "GET")
    public DataTablesResult selPaging(@PathVariable Integer page){
        int curentpage = page == null&&page==0 ? 1 : page;
        int pagesize=10;
        return new DataTablesResult(true,"日志记录",5200,service.selAll(curentpage,pagesize));
    }

}
